#include <DApplication>
#include <DApplicationSettings>
#include <DFontSizeManager>
#include <DMessageBox>
#include <DWidgetUtil>
#include <QTranslator>
#include <mainwindow.h>
DWIDGET_USE_NAMESPACE

int main(int argc, char *argv[]) {
  DECLARE_CONTENT("main")

  QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
  DApplication a(argc, argv);

  if (!a.setSingleInstance("WingMaye")) {
    DMessageBox::critical(nullptr, "", "", DMessageBox::Ok);
    exit(-1);
  }

  a.loadTranslator();

  auto s = a.applicationDirPath() + "/lang/zh.qm";

  QTranslator translator;
  if (!translator.load(s)) {
    DMessageBox::critical(nullptr, "", "", DMessageBox::Ok);
  }
  a.installTranslator(&translator);

  a.setOrganizationName("WingSummer");
  a.setApplicationName("WingMaye");
  a.setApplicationVersion("1.0");
  QIcon ico = QIcon(":/logo.ico");
  a.setProductIcon(ico);
  a.setProductName("Maye");
  auto appd = QT_TRANSLATE_NOOP("main", "AppDescription");
  a.setApplicationDescription(TRANS(appd));

  a.setApplicationDisplayName("Maye");

  // 保存程序的窗口主题设置
  DApplicationSettings as;
  Q_UNUSED(as)

  MainWindow w;
  w.show();

  Dtk::Widget::moveToCenter(&w);

  return a.exec();
}
